//
//  NSString+NotePath.m
//  iLiteNote
//
//  Created by xiangbc on 16/4/28.
//  Copyright © 2016年 LiteNice. All rights reserved.
//

#import "NSString+NotePath.h"


@implementation NSString(NotePath)

- (NSString*) getBaseName {
    NSRange r1 = [self rangeOfString:@"/" options:NSBackwardsSearch];
    NSRange r2 = [self rangeOfString:@"." options:NSBackwardsSearch];
    
    if (r1.length != 0) {
        if (r2.length != 0 && r2.location > r1.location) {
            return [self substringWithRange:NSMakeRange(r1.location+1, r2.location-r1.location-1)];
        } else {
            return [self substringFromIndex:r1.location+1];
        }
    } else {
        return @"";
    }
}

@end
